(ReadImage): lets get the offset right. This will let transparent gifs
author0 <jrb@redhat.com>
Sat, 30 Oct 1999 23:07:18 +0000 (23:07 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Sat, 30 Oct 1999 23:07:18 +0000 (23:07 +0000)
1999-10-30    <jrb@redhat.com>

(ReadImage): lets get the offset right.  This will let transparent
gifs work.

Right now, gifs with transparency, both interlaced and non-interlaced,
seem to work perfectly fine.  I haven't tried grayscale gifs yet, and I
seem to be getting offset in my RGB buffer with non-alpha gifs. )-:
This leads to pretty, but incorrect, images.

-Jonathan

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-gif.c

index abea3221074f65af07f0e319ffad80d302b638b0..af84ad89680976c9e0a28c0e5e5b710a77828cff 100644 (file)
@@ -3,6 +3,8 @@
        * src/io-gif.c: Some more work.  Now it generates a gdk_pixbuf of
        the right size, at a minimum, even if the image is squished and
        the wrong color.
+       (ReadImage): lets get the offset right.  This will let transparent
+       gifs work.
 
 1999-10-28  Jonathan Blandford  <jrb@redhat.com>
 
index 5f3d3cf0f2b36372223d357ed063309532358681..d3bbcbfedfc164e87d40299a9d66666447deb217 100644 (file)
@@ -74,7 +74,6 @@ struct _GifContext
        unsigned int aspect_ratio;
        int gray_scale;
        GdkPixbuf *pixbuf;
-       guchar used_cmap[3][256];
        Gif89 gif89;
 };
 
@@ -367,7 +366,6 @@ ReadImage (FILE *file,
        guchar c;
        gint xpos = 0, ypos = 0, pass = 0;
        gint v;
-       gint i, j;
 
        /*
        **  Initialize the Compression routines
@@ -377,6 +375,7 @@ ReadImage (FILE *file,
                return;
        }
 
+       g_print ("c = %d\n", c);
        if (LWZReadByte (file, TRUE, c) < 0) {
                /*g_message (_("GIF: error while reading\n"));*/
                return;
@@ -388,22 +387,20 @@ ReadImage (FILE *file,
                                          context->width,
                                          context->height);
 
-       for (i = 0, j = 0; i < ncols; i++) {
-               context->used_cmap[0][i] = cmap[0][i];
-               context->used_cmap[1][i] = cmap[1][i];
-               context->used_cmap[2][i] = cmap[2][i];
-       }
-
        dest = gdk_pixbuf_get_pixels (context->pixbuf);
        while ((v = LWZReadByte (file, FALSE, c)) >= 0) {
+//             g_print ("in inner loop: xpos = %d, ypos = %d\n", xpos, ypos);
                if (context->gif89.transparent) {
-                       temp = dest + ( (ypos * len) + xpos ) * 2;
-                       *temp = (guchar) v;
-                       *(temp+1) = (guchar) ((v == context->gif89.transparent) ? 0 : 255);
+                       temp = dest + (ypos * len + xpos) * 4;
+                       *temp = cmap [0][(guchar) v];
+                       *(temp+1) = cmap [1][(guchar) v];
+                       *(temp+2) = cmap [2][(guchar) v];
+                       *(temp+3) = (guchar) ((v == context->gif89.transparent) ? 0 : 65535);
                } else {
-
-                       temp = dest + (ypos * len) + xpos;
-                       *temp = (guchar) v;
+                       temp = dest + (ypos * len + xpos) * 3;
+                       *temp = cmap [0][(guchar) v];
+                       *(temp+1) = cmap [1][(guchar) v];
+                       *(temp+2) = cmap [2][(guchar) v];
                }
 
                xpos++;
@@ -448,8 +445,14 @@ ReadImage (FILE *file,
        }
 
  fini:
+       ypos = 0;
+/*     while (ReadOK (file, &c, 1) >= 0)
+       ypos++;
+       g_print ("ypos%d\n", ypos);*/
+/*
        if (LWZReadByte (file, FALSE, c) >= 0)
                g_print ("GIF: too much input data, ignoring extra...\n");
+*/
 }
 
 /* Shared library entry point */
@@ -516,6 +519,7 @@ image_load (FILE *file)
        }
 
        for (;;) {
+               g_print ("in loop\n");
                if (!ReadOK (file, &c, 1)) {
                        /*g_message (_("GIF: EOF / read error on image data\n"));*/
                        return context->pixbuf;